﻿using System;

namespace HB.Expand
{
    public static class String2Number
    {
        public static byte ToByte(this string s)
        {
            return byte.Parse(s);
        }
        public static byte ToByteFromHex(this string s)
        {
            return Convert.ToByte(s, 16);
        }
        public static sbyte ToSbyte(this string s)
        {
            return sbyte.Parse(s);
        }
        public static short ToShort(this string s)
        {
            return short.Parse(s);
        }
        public static ushort ToUshort(this string s)
        {
            return ushort.Parse(s);
        }
        public static ushort ToUshortFromHex(this string s)
        {
            return Convert.ToUInt16(s, 16);
        }
        public static int ToInt(this string s)
        {
            return int.Parse(s);
        }
        public static uint ToUint(this string s)
        {
            return uint.Parse(s);
        }
        public static uint ToUintFromHex(this string s)
        {
            return Convert.ToUInt32(s, 16);
        }
        public static long ToLong(this string s)
        {
            return long.Parse(s);
        }
        public static ulong ToUlong(this string s)
        {
            return ulong.Parse(s);
        }
        public static ulong ToUlongFromHex(this string s)
        {
            return Convert.ToUInt64(s, 16);
        }
        public static float ToFloat(this string s)
        {
            return float.Parse(s);
        }
        public static double ToDouble(this string s)
        {
            return double.Parse(s);
        }

        public static bool ToBool(this string boolString)
        {
            return bool.Parse(boolString.ToLower());
        }
    }
}
